package designMode.adapterPattern;

import java.util.Enumeration;
import java.util.Iterator;

/**
 * @author LIBOFEI
 * @ClassName IteratorEnumeration
 * @description  适配器模式  将Iterator适配为Enumeration
 * @date 2020/6/26 14:13
 * @Version 1.0
 **/
public class IteratorEnumeration implements Enumeration {

    Iterator iterator;

    public IteratorEnumeration(Iterator iterator){
        this.iterator = iterator;
    }

    @Override
    public boolean hasMoreElements() {
        return iterator.hasNext();
    }

    @Override
    public Object nextElement() {
        return iterator.next();
    }
}
